<template>
  <div class="bg">
    <!-- 头部 -->
    <Header title="运维管理—设备预警管理"></Header>

    <!-- 搜索栏 -->
    <section class="search_bar">
      <LInput label="设备名称" v-model="name"></LInput>
      <LInput label="规格型号" v-model="spec" style="margin-left: 16px"></LInput>
      <LSelect label="设备状态" :value="state" :options="option1" @selected-event="getNewSelected1" style="margin-left: 16px"></LSelect>
      <LSelect label="区域" :value="quyu" :options="option2" @selected-event="getNewSelected2" style="margin-left: 16px"></LSelect>
      <LSelect label="部门" :value="dep" :options="option3" @selected-event="getNewSelected3" style="margin-left: 16px"></LSelect>
      <LSelect label="设备系统" :value="esys" :options="option4" @selected-event="getNewSelected4" style="margin-left: 16px"></LSelect>
    </section>
    <section class="search_bar">
      <LSelect label="设备类别" :value="cate" :options="option5" @selected-event="getNewSelected5"></LSelect>
      <LInput label="距保修期(月)" v-model="no1" style="margin-left: 16px"></LInput>
      <LInput label="距使用期(月)" v-model="no2" style="margin-left: 16px"></LInput>
      <LSelect label="所属单位" :value="unit" :options="option6" @selected-event="getNewSelected6" style="margin-left: 16px"></LSelect>
      <LButton label="查询数据" style="margin-left: 16px"></LButton>
      <LButton label="重置条件" style="margin-left: 16px" @click="clearSelected"></LButton>
    </section>
    <!-- 标签页 -->
    <el-tabs type="border-card">
      <el-tab-pane label="临近保修期">
        <el-table :data="tableData1" style="width: 100%" :default-sort="{ prop: 'b', order: 'ascending' }" border>
          <el-table-column prop="a" label="设备名称" />
          <el-table-column prop="b" label="设备编码" width="100" />
          <el-table-column prop="c" label="规格型号" />
          <el-table-column prop="d" label="所属部门" />
          <el-table-column prop="e" label="安装位置" />
          <el-table-column prop="f" label="设备系统" />
          <el-table-column prop="g" label="设备类别" />
          <el-table-column prop="h" label="安装时间" />
          <el-table-column prop="i" label="保修年限" width="80" />
          <el-table-column label="操作" width="80">
            <template #default>
              <el-button type="success" size="small" @click="repairDialog = true">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="临近使用期">
        <el-table :data="tableData1" style="width: 100%" :default-sort="{ prop: 'b', order: 'ascending' }" border>
          <el-table-column prop="a" label="设备名称" />
          <el-table-column prop="b" label="设备编码" width="100" />
          <el-table-column prop="c" label="规格型号" />
          <el-table-column prop="d" label="所属部门" />
          <el-table-column prop="e" label="安装位置" />
          <el-table-column prop="f" label="设备系统" />
          <el-table-column prop="g" label="设备类别" />
          <el-table-column prop="h" label="安装时间" />
          <el-table-column prop="i" label="保修年限" width="80" />
          <el-table-column label="操作" width="80">
            <template #default>
              <el-button type="success" size="small" @click="repairDialog1 = true">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <!-- 临近保修期 弹出框：查看 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog" title="查看设备详情" width="40%" @close="repairDialogClose">
        <div class="dialog-border">
          <el-form label-width="120px" :model="repairForm" ref="repairFormRef" :rules="repairFormRules" size="mini">
            <div class="row-1">
              <el-form-item label="设备编码" prop="a" style="width:100%">
                <el-input v-model="repairForm.a" readonly></el-input>
              </el-form-item>
              <el-form-item label="设备名称" prop="b" style="width:100%">
                <el-input v-model="repairForm.b" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="序列号" prop="c" style="width:100%">
                <el-input v-model="repairForm.c" readonly></el-input>
              </el-form-item>
              <el-form-item label="出厂编号" prop="d" style="width:100%">
                <el-input v-model="repairForm.d" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="区域" prop="e" style="width:100%">
                <el-input v-model="repairForm.e" readonly></el-input>
              </el-form-item>
              <el-form-item label="部门" prop="f" style="width:100%">
                <el-input v-model="repairForm.e" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="设备系统" prop="g" style="width:100%">
                <el-input v-model="repairForm.e" readonly></el-input>
              </el-form-item>
              <el-form-item label="设备类别" prop="h" style="width:100%">
                <el-input v-model="repairForm.e" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="产地" prop="i" style="width:100%">
                <el-input v-model="repairForm.i" readonly></el-input>
              </el-form-item>
              <el-form-item label="状态" prop="j" style="width:100%">
                <el-select v-model="repairForm.j" filterable>
                  <el-option label="正常" value="1"></el-option>
                  <el-option label="维修" value="2"></el-option>
                </el-select>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="安装位置" prop="k" style="width:100%">
                <el-input v-model="repairForm.k" readonly></el-input>
              </el-form-item>
              <el-form-item label="品牌" prop="l" style="width:100%">
                <el-input v-model="repairForm.l" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="规格型号" prop="m" style="width:100%">
                <el-input v-model="repairForm.m" readonly></el-input>
              </el-form-item>
              <el-form-item label="供应商" prop="n" style="width:100%">
                <el-input v-model="repairForm.n" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="生产商" prop="o" style="width:100%">
                <el-input v-model="repairForm.o" readonly></el-input>
              </el-form-item>
              <el-form-item label="使用年限(年)" prop="p" style="width:100%">
                <el-input v-model="repairForm.p" placeholder="数字" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="保修期(年)" prop="q" style="width:100%">
                <el-input v-model="repairForm.q" placeholder="数字" readonly></el-input>
              </el-form-item>
              <el-form-item label="购置日期" prop="r" style="width:100%">
                <el-date-picker v-model="repairForm.r" type="date" readonly placeholder="格式：YYYY-MM-DD"></el-date-picker>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="安装日期" prop="s" style="width:100%">
                <el-date-picker v-model="repairForm.s" type="date" readonly placeholder="格式：YYYY-MM-DD"></el-date-picker>
              </el-form-item>
              <el-form-item label="设备原值(元)" prop="t" style="width:100%">
                <el-input v-model="repairForm.t" placeholder="数字" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="是否固资" prop="u" style="width:100%">

              </el-form-item>
              <el-form-item label="IP地址" prop="v" style="width:100%">
                <el-input v-model="repairForm.v" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="购资价(元)" prop="w" style="width:100%">
                <el-input v-model="repairForm.w" placeholder="数字" readonly></el-input>
              </el-form-item>
              <el-form-item label="分摊价(元)" prop="x" style="width:100%">
                <el-input v-model="repairForm.x" placeholder="数字" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="折旧率(%)" prop="y" style="width:100%">
                <el-input v-model="repairForm.y" placeholder="数字" readonly></el-input>
              </el-form-item>
              <el-form-item label="主维保方" prop="z" style="width:100%">
                <el-input v-model="repairForm.z" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="维保执行方" prop="aa" style="width:100%">
                <el-input v-model="repairForm.aa" readonly></el-input>
              </el-form-item>
              <el-form-item label="维保执行方地址" prop="ab" style="width:100%">
                <el-input v-model="repairForm.ab" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="维保执行方姓名" prop="ac" style="width:100%">
                <el-input v-model="repairForm.ac" readonly></el-input>
              </el-form-item>
              <el-form-item label="维保执行方电话" prop="ad" style="width:100%">
                <el-input v-model="repairForm.ad" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="维保起始日期" prop="ae" style="width:100%">
                <el-date-picker v-model="repairForm.ae" type="date" placeholder="格式：YYYY-MM-DD" readonly></el-date-picker>
              </el-form-item>
              <el-form-item label="维保起始结束" prop="af" style="width:100%">
                <el-date-picker v-model="repairForm.af" type="date" placeholder="格式：YYYY-MM-DD" readonly></el-date-picker>
              </el-form-item>
            </div>
            <div style="padding: 0 2vw 0 0">
              <el-form-item label="描述" prop="ag" style="width:100%">
                <el-input v-model="repairForm.ag" type="textarea" :rows="1" readonly></el-input>
              </el-form-item>
              <el-form-item label="文件资料" prop="ah" style="width:100%">
                <el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" multiple :limit="6" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <span style="font-size:8px"> (最多上传6个文件)</span>
                </el-upload>
              </el-form-item>
              <el-form-item label="设备二维码" prop="ag" style="width:100%">
              </el-form-item>
            </div>
          </el-form>
        </div>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="info" size="mini" @click="repairDialog1 = false">关闭</el-button>
          </span>
        </template>
      </el-dialog>
    </div>

    <!-- 临近使用期 弹出框：查看 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog1" title="查看设备详情" width="40%" @close="repairDialog1Close">
        <div class="dialog-border">
          <el-form label-width="120px" :model="repairForm1" ref="repairForm1Ref" :rules="repairForm1Rules" size="mini">
            <div class="row-1">
              <el-form-item label="设备编码" prop="a" style="width:100%">
                <el-input v-model="repairForm.a" readonly></el-input>
              </el-form-item>
              <el-form-item label="设备名称" prop="b" style="width:100%">
                <el-input v-model="repairForm.b" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="序列号" prop="c" style="width:100%">
                <el-input v-model="repairForm.c" readonly></el-input>
              </el-form-item>
              <el-form-item label="出厂编号" prop="d" style="width:100%">
                <el-input v-model="repairForm.d" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="区域" prop="e" style="width:100%">
                <el-input v-model="repairForm.e"></el-input>
              </el-form-item>
              <el-form-item label="部门" prop="f" style="width:100%">
                <el-input v-model="repairForm.e"></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="设备系统" prop="g" style="width:100%">
                <el-input v-model="repairForm.e"></el-input>
              </el-form-item>
              <el-form-item label="设备类别" prop="h" style="width:100%">
                <el-input v-model="repairForm.e"></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="产地" prop="i" style="width:100%">
                <el-input v-model="repairForm.i" readonly></el-input>
              </el-form-item>
              <el-form-item label="状态" prop="j" style="width:100%">
                <el-select v-model="repairForm.j" filterable>
                  <el-option label="正常" value="1"></el-option>
                  <el-option label="维修" value="2"></el-option>
                </el-select>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="安装位置" prop="k" style="width:100%">
                <el-input v-model="repairForm.k" readonly></el-input>
              </el-form-item>
              <el-form-item label="品牌" prop="l" style="width:100%">
                <el-input v-model="repairForm.l" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="规格型号" prop="m" style="width:100%">
                <el-input v-model="repairForm.m" readonly></el-input>
              </el-form-item>
              <el-form-item label="供应商" prop="n" style="width:100%">
                <el-input v-model="repairForm.n" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="生产商" prop="o" style="width:100%">
                <el-input v-model="repairForm.o" readonly></el-input>
              </el-form-item>
              <el-form-item label="使用年限(年)" prop="p" style="width:100%">
                <el-input v-model="repairForm.p" placeholder="数字" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="保修期(年)" prop="q" style="width:100%">
                <el-input v-model="repairForm.q" placeholder="数字" readonly></el-input>
              </el-form-item>
              <el-form-item label="购置日期" prop="r" style="width:100%">
                <el-date-picker v-model="repairForm.r" type="date" readonly placeholder="格式：YYYY-MM-DD"></el-date-picker>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="安装日期" prop="s" style="width:100%">
                <el-date-picker v-model="repairForm.s" type="date" readonly placeholder="格式：YYYY-MM-DD"></el-date-picker>
              </el-form-item>
              <el-form-item label="设备原值(元)" prop="t" style="width:100%">
                <el-input v-model="repairForm.t" placeholder="数字" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="是否固资" prop="u" style="width:100%">

              </el-form-item>
              <el-form-item label="IP地址" prop="v" style="width:100%">
                <el-input v-model="repairForm.v" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="购资价(元)" prop="w" style="width:100%">
                <el-input v-model="repairForm.w" placeholder="数字" readonly></el-input>
              </el-form-item>
              <el-form-item label="分摊价(元)" prop="x" style="width:100%">
                <el-input v-model="repairForm.x" placeholder="数字" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="折旧率(%)" prop="y" style="width:100%">
                <el-input v-model="repairForm.y" placeholder="数字" readonly></el-input>
              </el-form-item>
              <el-form-item label="主维保方" prop="z" style="width:100%">
                <el-input v-model="repairForm.z" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="维保执行方" prop="aa" style="width:100%">
                <el-input v-model="repairForm.aa" readonly></el-input>
              </el-form-item>
              <el-form-item label="维保执行方地址" prop="ab" style="width:100%">
                <el-input v-model="repairForm.ab" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="维保执行方姓名" prop="ac" style="width:100%">
                <el-input v-model="repairForm.ac" readonly></el-input>
              </el-form-item>
              <el-form-item label="维保执行方电话" prop="ad" style="width:100%">
                <el-input v-model="repairForm.ad" readonly></el-input>
              </el-form-item>
            </div>
            <div class="row-1">
              <el-form-item label="维保起始日期" prop="ae" style="width:100%">
                <el-date-picker v-model="repairForm.ae" type="date" placeholder="格式：YYYY-MM-DD" readonly></el-date-picker>
              </el-form-item>
              <el-form-item label="维保起始结束" prop="af" style="width:100%">
                <el-date-picker v-model="repairForm.af" type="date" placeholder="格式：YYYY-MM-DD" readonly></el-date-picker>
              </el-form-item>
            </div>
            <div style="padding: 0 2vw 0 0">
              <el-form-item label="描述" prop="ag" style="width:100%">
                <el-input v-model="repairForm.ag" type="textarea" :rows="1" readonly></el-input>
              </el-form-item>
              <el-form-item label="文件资料" prop="ah" style="width:100%">
                <el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" multiple :limit="6" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <span style="font-size:8px"> (最多上传6个文件)</span>
                </el-upload>
              </el-form-item>
              <el-form-item label="设备二维码" prop="ag" style="width:100%">
              </el-form-item>
            </div>
          </el-form>
        </div>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="info" size="mini" @click="repairDialog1 = false">关闭</el-button>
          </span>
        </template>
      </el-dialog>
    </div>

  </div>
</template>

<script>
import Header from "@/components/Header";
import moment from "moment";
import LInput from "../../../components/LInput.vue";
import LButton from "../../../components/LButton.vue";
import LDateTimeSelect2 from "@/components/LDateTimeSelect2.vue";
import LSelect from "@/components/LSelect.vue";
import LInput2 from "@/components/LInput2.vue";

export default {
  components: {
    Header,
    LInput,
    LButton,
    LDateTimeSelect2,
    LSelect,
    LInput2,
  },
  data() {
    return {
      name: "",
      spec: "",
      state: "1",
      quyu: "1",
      dep: "1",
      esys: "1",
      cate: "1",
      no1: "6",
      no2: "6",
      unit: "1",

      option1: [
        { label: "全部", value: "1" },
        { label: "正常", value: "2" },
        { label: "维护", value: "3" },
        { label: "报废", value: "4" },
      ],
      option2: [
        { label: "全部", value: "1" },
        { label: "梁山县水泊商务中心", value: "2" },
      ],
      option3: [
        { label: "全部", value: "1" },
        { label: "主楼", value: "2" },
        { label: "餐厅楼", value: "3" },
      ],
      option4: [
        { label: "全部", value: "1" },
        { label: "设备系统", value: "2" },
      ],
      option5: [
        { label: "全部", value: "1" },
        { label: "冷水机组", value: "2" },
        { label: "循环水泵", value: "3" },
      ],
      option6: [
        { label: "全部", value: "1" },
        { label: "机关事务局", value: "2" },
      ],
      tableData1: [
        {
          a: "大机房1#冷机",
          b: "01",
          c: "",
          d: "主楼",
          e: "主楼地下室大制冷机房",
          f: "公共设备",
          g: "冷水机组",
          h: "",
          i: "0",
        },
      ],
      repairDialog: false,
      repairForm: {},
    };
  },
  mounted() {},
  beforeUnmount() {},
  methods: {
    //获取搜索栏“设备状态”选项
    getNewSelected1(s) {
      this.state = s;
    },
    //获取搜索栏“区域”选项
    getNewSelected1(s) {
      this.quyu = s;
    },
    //获取搜索栏“部门”选项
    getNewSelected1(s) {
      this.dep = s;
    },
    //获取搜索栏“设备系统”选项
    getNewSelected1(s) {
      this.esys = s;
    },
    //获取搜索栏“设备类别”选项
    getNewSelected1(s) {
      this.cate = s;
    },
    //获取搜索栏“所属单位”选项
    getNewSelected1(s) {
      this.unit = s;
    },
    //搜索栏“重置条件”按钮
    clearSelected() {
      this.name = "";
      this.spec = "";
      this.state = "1";
      this.quyu = "1";
      this.dep = "1";
      this.esys = "1";
      this.cate = "1";
      this.no1 = "6";
      this.no2 = "6";
      this.unit = "1";
    },
  },
};
</script>

<style lang="less" scoped>
@import "../opera.less";

.search_bar {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.row-1 {
  display: flex;
  justify-content: space-between;
  padding: 0 2vw 0 0;
}

/deep/ .el-dialog .el-select {
  width: 215px;
}

/deep/ .el-dialog .el-date-picker {
  width: 210px;
}
</style>